package com.xyz.auth.controller;

import cn.hutool.core.codec.Base64;
import com.alibaba.fastjson.JSONObject;
import com.xyz.auth.common.R;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * 模拟登陆服务，不需要登陆访问
 */
@RestController
@RequestMapping("/auth")
public class LoginController {

    @RequestMapping(value ="/login", method = RequestMethod.GET, produces = "application/json;charset=UTF-8")
    @ResponseBody
    public R login(String userName) {
        JSONObject token = new JSONObject();
        token.put("userName",userName);
        token.put("token", "Basic "+ Base64.encode("a:123"));
        return R.ok(token);
    }
}
